package com.hyts.standard.webflux.r2db.service;

import com.hyts.standard.webflux.bean.po.Users;
import com.hyts.standard.webflux.r2db.dao.UserDao;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

/**
 * @author wayne
 * @version UsersService,  2020/9/13
 */
@Component
public class UserService {


    @Resource
    private UserDao userDao;


//    @Transactional
    public Mono<Users> save(Users user) {
        return userDao.save(user).map(it -> {
            if (it.getFirstname().equals("flydean")) {
                throw new IllegalStateException();
            } else {
                return it;
            }
        });
    }

}
